package com.feng.util;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

public class FileUtils {

	public static byte[] getByteArray(String path) {
		byte[] buffer = null;
		ByteArrayOutputStream bos = new ByteArrayOutputStream(1000);
		byte[] b = new byte[1000];
		int len = 0;
		File f1 = new File(path);
		InputStream in = null;
		try {
			in = new FileInputStream(f1);
			while ((len = in.read(b)) != -1) {

				bos.write(b, 0, len);
			}
			buffer = bos.toByteArray();

		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				bos.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			try {
				in.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return buffer;
	}
}
